<%-- 
    Document   : movieedit
    Created on : Jul 22, 2012, 10:38:01 AM
    Author     : Atienza-Home
--%>

<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Factory.Tables.Movie"%>
<%@page import="Factory.Tables.Category"%>


<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%
   
    Movie movieedit = (Movie)session.getAttribute("pickToEditMovie");
    ArrayList<Category> result = (ArrayList<Category>)session.getAttribute("categories");
    Iterator<Category> iter;
    Category category;
    
%>

<form name="MovieEditForm" action="javascript:movieEdit(<%=movieedit.getId()%>,'<%=movieedit.getMoviePic()%>','<%=movieedit.getName()%>','<%=movieedit.getDescription()%>','<%=movieedit.getReleaseDate()%>',<%=movieedit.getCategoryID()%>,<%=movieedit.getActive()%> );" method="GET">

    <div id="moviename" style=" padding: 10px; background-color: #006666">
        <div id="spanmoviename" class="<%=movieedit.getName()%>" ><font color="white" style=" font-size: 25px;font-weight: bold;"><%=movieedit.getName()%> <font style="font-weight:normal;font-size:15px;">[<a href="javascript:changeName()">Edit</a>]</font> </font></div>
    
    </div>
        <%
    
    
            
    try{
    if(!movieedit.getMoviePic().isEmpty()){
        %>
        <div id="moviepic" style=" padding: 10px; background-color: #009999">
            <img id='specificmoviepic' src="../images/movie/<%=movieedit.getMoviePic()%>" name="<%=movieedit.getMoviePic()%>" width="200px" />
            <input id="moviepicbrowse"  type="file" onchange="javascript:changepic();">
        </div>
        <%
                
    }
    }catch(Exception e){
        %>
        <div id="moviepic" style=" padding: 10px; background-color: #009999">
            <font color="white">It seems like you don't put a picture yet.Click "Browse" below.</font><br>
                       
            <input id="moviepicbrowse"  type="file" onchange="javascript:changepic();">
            
        </div>
        
        
        <%
    }
    
    %>
    <div id="moviecategory" style=" padding: 10px; background-color: #006666">
        <font color="white">Category:</font>
        <select id="moviecategoryselect">
        <%
        int i;
        if(result!=null){
            iter = result.iterator(); 
            i=0;
            while(iter.hasNext()){
                category = iter.next();
            
                if(movieedit.getCategoryName().equals(category.getCategoryName())){
                %>
                    <option value="<%=category.getCategoryID()%>" selected="selected"><%=category.getCategoryName()%></option>    
                
                <%
                }
                else{
                %>
                    <option value="<%=category.getCategoryID()%>"><%=category.getCategoryName()%></option>    
                <%
                }
            
                i++;               
            }
        }
    

        %>                
        </select>
    
    </div>    
    
    <div id="moviereleasedate" style=" padding: 10px; background-color: #009999">
        <font color="white">Release Date(YYYY-MM-DD):</font><br>
        <input id="editmoviereleasedate" type="text" value="<%=movieedit.getReleaseDate()%>">
      
            
    </div>
        
    <div id="movieprice" style=" padding: 10px; background-color: #009999">
        <font color="white">Price:</font><br>
        <input id="editmovieprice" min="0" type="number" value="<%=movieedit.getPrice()%>">
      
            
    </div>
           
    <div style=" padding: 10px; background-color: #006666;">
        <font color="white" style="font-weight: bold;">Description:</font><br>
        <div id="moviedescription">
            <div id="spanmoviedesc" class="<%=movieedit.getDescription()%>" ><font color="white">&nbsp;&nbsp;<%=movieedit.getDescription()%>[<a href="javascript:changeDescription()"> Edit</a>]</font><br></div>
        </div>
        
    </div>

    
    <div id="submiteditmovie" style="padding: 0px;">
        <input type="submit" value="Update" style="padding:5px; width: 990px; " />            
    </div>    
   
    
</form>

